<?php
if (file_exists('api.xml')) {
    $xml = simplexml_load_file('api.xml');
 
    print_r($xml);
	var_dump($xml);
} else {
    exit('Failed to open API.');
}
echo $xml->basic->upto;
echo '<hr><br>';
function simplexml_obj2array($obj) {   
    if( count($obj) >= 1 )
    {
        $result = $keys = array();
       
        foreach( $obj as $key=>$value)
        {  
            isset($keys[$key]) ? ($keys[$key] += 1) : ($keys[$key] = 1);
           
            if( $keys[$key] == 1 )
            {
                $result[$key] = simplexml_obj2array($value);
            }
            elseif( $keys[$key] == 2 )
            {
                $result[$key] = array($result[$key], simplexml_obj2array($value));
            }
            else if( $keys[$key] > 2 )
            {
                $result[$key][] = simplexml_obj2array($value);
            }
        }
        return $result;
    }
    else if( count($obj) == 0 )
    {
        return (string)$obj;
    }
}
   echo '<pre>';
   print_r(simplexml_obj2array($xml));
   echo '</pre>';
?> 
